const express = require('express')
const path = require('path')
const app = express()


//解决跨域请求问题
app.all('*', function (req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "X-Requested-With");
    res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
    res.header("X-Powered-By", ' 3.2.1');
    next();
});

//前台文件路径
app.use("/chat", express.static(path.join('../', 'public/webSocket')));

// 监听端口 启动客服前台服务端
var chat = app.listen(9527, '127.0.0.1', () => {
    var host = chat.address().address;
    var port = chat.address().port;
    console.log("地址为 http://%s:%s", host, port + '/chat/index.html');
})